#! /bin/bash
#SQOOP_HOME=/opt/cloudera/parcels/CDH-6.2.1-1.cdh6.2.1.p0.1425774/bin/sqoop
SQOOP_HOME=/usr/bin/sqoop

if [[ $1 == '' ]];
then dt=`date -d '-1 day' "+%Y-%m-%d"`
else dt=$1
fi


/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/teach?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select * from calendar where 1=1 and  \$CONDITIONS" \
--hcatalog-database zx_ods \
--hcatalog-table ods_calendar \
-m 1


/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/teach?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select *,'${dt}' dt from class_studying_student_count where 1=1 and (studying_date between '${dt} 00:00:00' and '${dt} 23:59:59') and  \$CONDITIONS" \
--hcatalog-database zx_ods \
--hcatalog-table ods_class_studying_student_count \
-m 1


/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/teach?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select *,'${dt}' dt from course_table_upload_detail where 1=1 and class_date = '${dt}' and  \$CONDITIONS" \
--hcatalog-database zx_ods \
--hcatalog-table ods_course_table_upload_detail \
-m 1


/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/teach?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select *,'${dt}' dt from student_leave_apply where 1=1 and substr(begin_time,1,10) = '${dt}' and  \$CONDITIONS" \
--hcatalog-database zx_ods \
--hcatalog-table ods_student_leave_apply \
-m 1


/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/teach?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select * from tbh_class_time_table where 1=1 and  \$CONDITIONS" \
--hcatalog-database zx_ods \
--hcatalog-table ods_tbh_class_time_table \
-m 1


/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/teach?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select *,'${dt}' dt from tbh_student_signin_record where 1=1 and (signin_date between '${dt} 00:00:00' and '${dt} 23:59:59') and  \$CONDITIONS" \
--hcatalog-database zx_ods \
--hcatalog-table ods_tbh_student_signin_record \
-m 1
